home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d4 / abermud.arc / GMAINSTU.C < prev    next >
C/C++ Source or Header  |  1991-04-28  |  2KB  |  123 lines

  1. #include <stdio.h>
  2. #include <sys/errno.h>
  3. #include <sys/file.h>
  4. #include "object.h"
  5. #include "System.h"
  6.  
  7. void qcrypt(in,out,len)
  8. char *in,*out;
  9. {
  10.     strncpy(out,in,len);
  11. }
  12.  
  13. void dcrypt(in,out,len)
  14. char *in,*out;
  15. {
  16.     strncpy(out,in,len);
  17. }
  18.  
  19. void cls()
  20. {
  21. /*
  22.  *    This isnt used on unix
  23.  *
  24.  */
  25.     ;
  26. }
  27.  
  28. int ttyt=0;
  29.  
  30. void getty()
  31. {
  32. /*
  33.  *    We dont use this on the unix version
  34.  *
  35.  */
  36.     
  37.     ;
  38. }
  39.  
  40. FILE *openlock(file,perm)
  41. char *file;
  42. char *perm;
  43.     {
  44.     FILE *unit;
  45.     long ct;
  46.     extern int errno;
  47.     extern char globme[];
  48.     ct=0;
  49.    unit=fopen(file,perm);
  50.    if(unit==NULL) return(unit);
  51.    /* NOTE: Always open with R or r+ or w */
  52. intr:if(flock(fileno(unit),LOCK_EX)== -1)
  53.         if(errno==EINTR) goto intr; /* INTERRUPTED SYSTEM CALL CATCH */
  54.     return(unit);
  55.     }
  56.  
  57. void fcloselock(file)
  58. FILE *file;
  59. {
  60.     flock(fileno(file),LOCK_UN);
  61.     fclose(file);
  62. }
  63.     
  64.  
  65. int validname(name)
  66.  char *name;
  67.     {
  68.     long a;
  69.     if(resword(name)){printf("Sorry I cant call you that\n");return(0);  }
  70.     if(strlen(name)>10)
  71.        {
  72.        return(0);
  73.        }
  74.     a=0;
  75.     while(name[a])
  76.        {
  77.        if(name[a]==' ')
  78.           {
  79.           return(0);
  80.           }
  81.        a++;
  82.        }
  83.     if(fobn(name)!=-1)
  84.        {
  85.       printf("I can't call you that , It would be confused with an object\n");
  86.        return(0);
  87.        }
  88.     return(1);
  89.     }
  90.  
  91. int resword(name)
  92. {
  93. if(!strcmp(name,"The")) return(1);
  94. if(!strcmp(name,"Me")) return(1);
  95. if(!strcmp(name,"Myself")) return(1);
  96. if(!strcmp(name,"It")) return(1);
  97. if(!strcmp(name,"Them")) return(1);
  98. if(!strcmp(name,"Him")) return(1);
  99. if(!strcmp(name,"Her")) return(1);
  100. if(!strcmp(name,"Someone")) return(1);
  101. if(!strcmp(name,"There")) return(1);
  102. return(0);
  103. }
  104.  
  105.     
  106.  
  107. extern OBJECT objects[];
  108.  
  109. fobn(name)
  110. char *name;
  111. {
  112.     int ct=0;
  113.     char x[32];
  114.     strcpy(x,name);
  115.     lowercase(x);
  116.     while(ct<NOBS)
  117.     {
  118.         if(strcmp(x,objects[ct].o_name)==0) return(ct);
  119.         ct++;
  120.     }
  121.     return(-1);
  122. }
  123.